﻿Public Class NavPoint
    Private mTitle As String
    Private mCode As String

    Private mObjectId As String
    Private mTokenName As String
    Private mArgIndex As Integer = -1
    Private mArgMatch As String

    Public Property objectType As ObjectType?
    Public Property deselectOthers As Boolean = True

    Public Sub New(title As String, code As String)
        Me.New(title, code, Nothing)
    End Sub

    Public Sub New(title As String, code As String, objectType As ObjectType?)
        mTitle = title
        mCode = code

        Dim parts() As String = code.Split(":"c)
        If parts.Length >= 1 Then
            mObjectId = parts(0)
        Else
            mObjectId = Nothing
        End If
        If parts.Length >= 2 Then
            mTokenName = parts(1)
        Else
            mTokenName = Nothing
        End If
        If parts.Length >= 4 Then
            Integer.TryParse(parts(2), mArgIndex)
            mArgMatch = parts(3)
        Else
            mArgIndex = -1
            mArgMatch = Nothing
        End If
        objectType = objectType
    End Sub

    Public ReadOnly Property Title As String
        Get
            Return mTitle
        End Get
    End Property

    Public ReadOnly Property Code As String
        Get
            Return mCode
        End Get
    End Property

    Public ReadOnly Property ObjectId As String
        Get
            Return mObjectId
        End Get
    End Property

    Public ReadOnly Property TokenName As String
        Get
            Return mTokenName
        End Get
    End Property

    Public ReadOnly Property ArgIndex As Integer?
        Get
            If mArgIndex >= 0 Then
                Return mArgIndex
            Else
                Return Nothing
            End If
        End Get
    End Property

    Public ReadOnly Property ArgMatch As String
        Get
            Return mArgMatch
        End Get
    End Property
End Class
